#include<stdio.h>
int main()
{
	int A,Da,B,Db,Pa=0,Pb=0,sum=0;
	scanf("%d %d %d %d",&A,&Da,&B,&Db);
	while(A>0)
	{
		if(Da == A%10)	
			Pa=Da+Pa*10;
			A/=10;
	}
	while(B>0)
	{
		if(Db == B%10)	
			Pb=Db+Pb*10;
			B/=10;
	}
	sum = Pa+Pb;
	printf("%d",sum);
	return 0;
}